var Api = "http://192.168.5.13:9000/";
var Apo = new Vue({
      el: "#app",   
	  created() {
	  	this.List();	
	  },
      data: function () {
		return{
		tableData: [],
		pageNum: 1,
		pageSize: 10,
		total: 0,
		};
      },
      computed: {
      
      },
	              methods:{
					  //
					     open(id) {
					          this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
					            confirmButtonText: '确定',
					            cancelButtonText: '取消',
					            type: 'warning'
					          }).then(() => {
								Apo.del(id);
					          }).catch(() => {
					            this.$message({
					              type: 'info',
					              message: '已取消删除'
					            });          
					          });
					        },
					 //删除列表
					del:function(id){
						let that = this;
					                //发生请求
									that.id= id 
					                axios({
										method: "post",
										url: Api + "upDown/delete?id=" + id,
									}).then(function (res) {
					                 if (res.data.code == "101") {
					                   that.$message({
					                     type: "success",
					                     message: res.data.message,
					                   });
									    window.location.href = "002.html";
					                 } else {
					                   that.$message({
					                     type: "error",
					                     message: res.data.message,
					                   });
					                 }
					               });
							},
					//显示上下级列表
					  List() {
					        let that = this;
					              var par = {
					                  pageNum: that.pageNum,
					                  pageSize: that.pageSize
					              }
					              axios({
					                  method: "post",
					                  url: Api + "equip/upDownUserList",
					                  params: par
					              }).then(function (res) {
					                  console.log(res);
					                  if (res.data.code == "101") {
					                      that.tableData = res.data.data
					                      // that.total = res.data.totalRow
					      }
					                  if (res.data.code == "102"){
					                      that.$message({
					                          type: "error",
					                          message: res.data.message
					                      })
					                  }
					              })
					    },
						// 
						add(){
							window.location.href="useradd.html";
						},
						update(id){
							window.location.href = "userUpdate.html";
							window.localStorage.setItem("uid", id)
						},
						//  弹出框的全选
						handleSelectionChange(val) {
						    console.log(val);
						    var arr = []
						    let that = this
						    for(const item in val) {
						        arr.push(val[item].id)
						    }
						    that.userId = arr
						},
						//  分页
						handleSizeChange(val) {
						    console.log(`每页 ${val} 条`)
						},
						handleCurrentChange(val) {
						    console.log(`当前页: ${val}`)
						}
	  }
	})
